tdf#124025 Update formula before printing

Reintroduce the UpdateFields call, but guard it so that
it does not modify the doc (as it was before)

Change-Id: I23e814f0b5d900d145dc82272034f03e66c079ed
Reviewed-on: https://gerrit.libreoffice.org/69696
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 345fcba..0cd8e2f 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2614,23 +2614,25 @@
            // since printing now also use the API for PDF export this option
            // should be set for printing as well ...
            pViewShell->SetPDFExportOption( true );
            bool bOrigStatus = pRenderDocShell->IsEnableSetModified();
            // check configuration: shall update of printing information in DocInfo set the document to "modified"?
            bool bStateChanged = false;
            if ( bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
            {
                pRenderDocShell->EnableSetModified( false );
                bStateChanged = true;
            }

            if( bStateChanged )
                pRenderDocShell->EnableSetModified();

            // tdf#122607 Re-layout the doc. Calling CalcLayout here is not enough, as it depends
            // on the currently visible area which is 0 when doing headless conversion.
            pViewShell->Reformat();
            pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );


            // #122919# Force field update before PDF export, but after layout init (tdf#121962)
            bool bStateChanged = false;
            // check configuration: shall update of printing information in DocInfo set the document to "modified"?
            if ( pRenderDocShell->IsEnableSetModified() && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
            {
                pRenderDocShell->EnableSetModified( false );
                bStateChanged = true;
            }
            pViewShell->SwViewShell::UpdateFields(true);
            if( bStateChanged )
                pRenderDocShell->EnableSetModified();

            pViewShell->SetPDFExportOption( false );

            // enable view again